package com.singzi.leetcode.N400;

import java.util.ArrayList;
import java.util.List;

public class T0373 {
}
class Solution0373 {
    private List<List<Integer>> result = new ArrayList<>();
    public List<List<Integer>> kSmallestPairs(int[] nums1, int[] nums2, int k) {
        int i = 0, j = 0, count = 0;
        while(count<k){
            List<Integer> list = new ArrayList<>();
            list.add(nums1[i]);
            list.add(nums1[j]);
            result.add(list);
            count++;
            if(i == nums1.length-1) j = j+1;
            else if(j == nums2.length-1) i = i+1;
            else{
                if(nums1[i]+nums2[j+1] < nums1[i+1]+nums2[j]) j = j+1;
                else i = i+1;
            }

        }
        return result;
    }
}